<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class VersionRequest extends FormRequest
{
    protected array $scenes = [
        'add' => ['type',  'version', 'version_code', 'desc', 'url'],
        'edit' => ['id', 'type',  'version', 'version_code', 'desc', 'url'],
    ];
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'id' => 'required|integer',
            'type' => 'required',
            'version' => 'required|integer',
            'version_code' => 'required',
            'desc' => 'required',
            'url' => 'required',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'id.required' => '参数错误-0',
            'id.integer' => '参数错误-1',
            'type.required' => '类型错误',
            'version.required' => '版本格式错误-1',
            'version.integer' => '版本格式错误-2',
            'version_code.required' => '版本号错误',
            'desc.required' => '必须填写描述',
            'url.required' => '必须填写下载地址',
        ];
    }
}
